package com.ricky.handler;

import org.apache.log4j.Logger;

public class HandlerFactory {

	private static String domain = "com.ricky.handler.";

	protected static Logger log = Logger.getLogger(HandlerFactory.class);

	/** 链接和登录相关 */
	public final static String Package_authorise = "authorise";
	
	public final static String Auth_prefix="au";

	/** 角色行动相关 */
	public final static String Package_Action = "action";
	
	public final static String Action_prefix="ac";

	/**
	 * 创建处理程序
	 * 
	 * @param url
	 * @return
	 */
	public static IHandler createHandler(String parentPackage,
			String handlerName) {
		String namespace = domain + parentPackage + "." + handlerName;
		IHandler handler = null;
		try {
			handler = (IHandler) Class.forName(namespace).newInstance();
			log.info("工厂化" + namespace);
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}

		return handler;
	}

}
